/**
 * 
 */
package com.zc.springproject.serviceimpl;

import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.zc.springproject.dao.UserDAO;
import com.zc.springproject.javabean.User;

/**
 * @author ZhangCheng
 * @time 2019年10月31日
 */
@Service
public class UserServiceImpl{
	@Autowired
	@Qualifier("userDAO")
	private UserDAO uDAO;
	public int insertNewInfo(User u){
		try {
			return uDAO.insertNewUser(u);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return -1;
		}
	}
	public User getUserInfo(String name) {
		return uDAO.getUserInfoById(name);
	}
	public boolean isRigthPwd(String name,String pwd) {
		if(name == null||pwd==null) {
			return false;
		}
		User u = uDAO.getUserInfoById(name);
		if(u == null) {
			return false;
		}else {
			if(pwd.equals(u.getPwd())) {
				return true;
			}else {
				return false;
			}
		}
	}
}
